package net.zoneland.knowledge.service.impl;

import net.zoneland.knowledge.dao.PartyGroupMapper;
import net.zoneland.knowledge.service.PartyGroupService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

/**
 * 党组织小组服务实现
 */
@Service
public class PartyGroupServiceImpl implements PartyGroupService {

    /**
     * 党小组织数据接口.
     */
    @Autowired
    private PartyGroupMapper partyGroupMapper;

    /**
     * 根据组织uuids获取组织小组uuids
     * @param orgUuids 组织uuids
     * @return 组织小组uuids
     */
    @Override
    public List<String> getPartyGroupOrgUuids(final List<String> orgUuids) {
        return Optional.ofNullable(orgUuids)
                .filter(CollectionUtils::isNotEmpty)
                .map(partyGroupMapper::getOrgGroupUuidByParentIds)
                .orElseGet(ArrayList::new);
    }

}
